<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<!-- 引入样式 -->
		<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
		<!-- 引入组件库 -->
		<script src="./js/vue.js" type="text/javascript" charset="utf-8"></script>
		<script src="./js/axios.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="https://unpkg.com/element-ui/lib/index.js"></script>
		<style type="text/css">
			body {
			    /* background-image: url("img/星空.jpg"); */
			    background-repeat: no-repeat;
			    background-size: 100% 100%;
			    background-attachment: fixed;      /*图片铺满整个页面*/
			}
			.main {
			    width: 500px;
			    height: 300px;
			    box-shadow: 0 5px 20px 0 #e8e8e8;
			    background-color: white;
			    border-radius: 10px;
			    position: absolute;
			    top: 0;
			    right: 0;
			    bottom: 0;
			    left: 0;
			    margin: auto;
			}
			.main h2 {
			    color: lightseagreen;
			    margin-left: 150px;
			}
			.form {
			    margin-top: 30px;
			    margin-left: 60px;
			}
			.form select{
				width: 305px;
				height: 30px;
				margin: 6px 50px;
			}
			.form input {
			    width: 300px;
			    height: 25px;
			    border: 1px solid lightgray;
			    outline: none;      /*输入内容时不显示边框*/
				margin: 6px 50px;
			}
			.form button {
			    width: 150px;
			    height: 30px;
			    color: white;
			    background-color: lightseagreen;
			    border-style: none;
			    border-radius: 5px;
			    font-size: 15px;
			    margin-top: 15px;
			    margin-left: 130px;
			    outline: none;
			    cursor: pointer;    /*光标放到上面有小手*/
			}
		</style>
	</head>
	<body>
		<div class="main">
		    <h2>欢迎访问医务室系统</h2>
				<div class="form">
					<select name="sel" v-model="identity">
						<option value='iden'>请选择登录身份</option>
						<option value="doctor">校医</option>
						<option value="student">学生</option>
					</select><br>
					<input type="text" name="username" placeholder="用户名" v-model="userName"><br>
					<input type="password" name="password" placeholder="密码" v-model="password"><br>
					<button @click='loginBtn'>登录</button><br>
				</div>
				
	
		</div>
	</body>
	<script>
		new Vue({
			el:'.main',
			 data() {
			      return {
			        identity:'iden',
					userName:'',
					password:'',
					
			      }
			    },
			    methods: {
			      async loginBtn(){
					  if(this.identity === 'iden'){
						  alert('请选择身份')
					  }else if(this.identity === 'doctor'){
						  const {data: res} =  await axios.post('http://47.115.220.91:8787/commons/loginCheckOfDoctor?userName='+this.userName+'&password='+this.password);
						  console.log(res ,"===", res.code, "====", res.data);
						if(res.code === 1){
							window.location = "html/DoctorPage.html"
							window.sessionStorage.setItem('islogin','true')
							window.sessionStorage.setItem('doctorName',JSON.stringify(this.userName))
							setTimeout(()=>{
								alert(res.data)
								console.log(res ,"===", res.code, "====", res.data);
							},500)
						}else{
							alert(res.msg)
						}
					  }else{
						  const {data: res} =  await axios.post('http://47.115.220.91:8787/commons/loginCheckOfStudent?userName='+this.userName+'&password='+this.password);
						  if(res.code === 1){
							  window.location = "html/index.html"
							  window.sessionStorage.setItem('studentName',JSON.stringify(this.userName))
							  window.sessionStorage.setItem('islogin','true')
							  setTimeout(()=>{
							  	alert(res.data)
							  },500)
						  }else{
							  alert(res.msg)
						  }
						  // res.code === 1 ? alert(res.data) : alert(res.msg)
						  // window.location = "html/index.html"
						  // window.sessionStorage.setItem('studentName',JSON.stringify(this.userName))
						  // window.sessionStorage.setItem('islogin','true')
					  }
				  }
			    }
		})
	</script>
</html>
